﻿(function () {
    'use strict';
    var serviceId = 'dataContext';

    angular.module('common').factory(serviceId,
    ['httpRequestSvc', 'inMemoryData', dataContext]);

    function dataContext(httpRequestSvc, inMemoryData) {
        var service = {
            getPeople: getPeople,
            addPerson: addPerson
        };

        return service;

        function getPeople() {
            {
                //var url = "/bigData.json";
                var url = "/smallData.json";
                //var url = "http://www.json-generator.com/j/bOAZfqRDNe?indent=4";
            }
            httpRequestSvc.getJson(url).then(
               function (data) {
                   inMemoryData.peopleList = data;
               }, function (err) {
                   alert(err);
               });
        }

        function addPerson() {
            inMemoryData.peopleList.push(
                  {
                      "name": "New Item",
                      "age": "new age",
                      "id": "",
                      "address": "145 New Street, NewLand, New City, 14197",
                      "balance": "$4,154.00",
                      "company": "New Company",
                      "email": "newEmail@new.com"
                  });
        }
        //#region Internal Methods        

        //#endregion
    }
})();